package com.atu.atugra.service.impl;
 
import com.atu.atugra.tools.CommonResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atu.atugra.mapper.CategoriesMapper;
import com.atu.atugra.entity.Categories;
import com.atu.atugra.service.CategoriesService;
import javafx.scene.control.Pagination;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Categories)表服务实现类
 *
 * @author makejava
 * @since 2025-02-07 12:02:56
 */
@Service("categoriesService")
public class CategoriesServiceImpl extends ServiceImpl<CategoriesMapper, Categories> implements CategoriesService {

    @Override
    public CommonResult Categorylist(Integer currentPage, Integer pageSize,String key) {
        LambdaQueryWrapper<Categories> queryWrapper = new LambdaQueryWrapper<Categories>();
        Page<Categories> categoryPage = new Page<>(currentPage, pageSize);
        queryWrapper.ne(Categories::getCategoryId, 1);
        if(key!=null){
            queryWrapper.like(Categories::getCategoryName, key);
            this.page(categoryPage,queryWrapper);
            return CommonResult.okResult(categoryPage);
        }
        this.page(categoryPage,queryWrapper);
        return CommonResult.okResult(categoryPage);
    }

    @Override
    public CommonResult all() {
        LambdaQueryWrapper<Categories> queryWrapper = new LambdaQueryWrapper<Categories>();
        queryWrapper.ne(Categories::getCategoryId, 1);
        return CommonResult.okResult(this.list(queryWrapper));
    }
}
